# 想构造一个字典，它是另外一个字典的子集

prices = {
    'ACME':45.23,
    'AAPL':612.64,
    'IBM':205.49,
    'HPQ':37.21,
    'FB':10.28
}

# 使用字典推导
def demo_1():
    # 推导value大于200的元素为map
    p1 = {key: value for key, value in prices.items() if value > 200}
    print(p1)
    tech_names = {'AAPL', 'IBM', 'HPQ', 'MSFT'}
    # 推导元素key在资源集合里的元素为map
    p2 = {key: value for key, value in prices.items() if key in tech_names}
    print(p2)

if __name__ == '__main__':
    demo_1()